import { createConnection, Connection } from "typeorm";
import path from "path";

const connection = createConnection({
  type: "postgres",
  host: "localhost",
  port: 5432,
  username: "postgres",
  password: "postgres",
  database: "demo",
  entities: [
    path.resolve(__dirname, "./*.js"),
    // "../entity/**/*.ts",
    // "../entity/**/*.js",
  ],
  synchronize: true,
  logging: false,
  entityPrefix: "",
})
  .then((connection) => {
    // here you can start to work with your entities
    // baas = connection;
    console.info("typeorm connected");
    // connection.query('select current_date').then(console.log);
  })
  .catch((error) => {
    console.error(error);
    console.error("typeorm error");
    // console.log(error)
  });
